package com.his.controller;

import com.his.annotation.RequireRoles;
import com.his.common.Const;
import com.his.common.PageParam;
import com.his.common.Rsp;
import com.his.entity.Log;
import com.his.service.LogService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * 日志查看删除
 */
@Validated
@RestController
@RequestMapping("log")
public class LogController {
    @Resource
    private LogService logService;

    @RequireRoles(roles = {"admin"}, index = 0)
    @PostMapping("getAll")
    public Rsp getAll(@RequestHeader(Const.TOKEN) String token, @RequestBody PageParam<Log> pageParam) {
        return logService.getAll(pageParam);
    }

    @RequireRoles(roles = {"admin"}, index = 0)
    @GetMapping("del")
    public Rsp del(@RequestHeader(Const.TOKEN) String token, @NotNull Integer id) {
        return logService.del(id);
    }
}
